package com.zhn.evsi.client;

import com.alibaba.fastjson.JSONObject;
import com.dtflys.forest.annotation.BaseRequest;
import com.dtflys.forest.annotation.Request;
import com.dtflys.forest.annotation.Retry;
import com.dtflys.forest.annotation.Var;
import com.zhn.evsi.domain.dto.evsi.market.EvsiMarketOrderDTO;
import com.zhn.evsi.interceptor.TokenInterceptor;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.concurrent.Future;


@Component
@BaseRequest(baseURL = "${eveData}${eveDataSns}")
@Retry(maxRetryCount = "3", maxRetryInterval = "1000")
public interface MarketClient {

    /**
     * 查询产品订单
     * */
    // https://esi.evetech.net/latest/characters/2119634223/orders/?datasource=tranquility&token=1%7CCfDJ8LAoxfuX0s1GlKTIRpDOTgodLWBjZi1Wfrt2gGFQnlPUIZHB6odJ%2Fp%2FNmHxMYv0LO%2FVuVEgk2jNqkAdLs0dE4ybcfDvPZSLBLJS67%2BTSQHUPOs1YV5de8ZD4uzfN%2Fmu%2FNMU4TYSrGeW3%2BQOOZznVApnBicQqnDODOCDpqibqfqFf
    @Request(
            url = "/characters/{characters}/orders/?datasource=tranquility",
            type = "GET",
            interceptor = TokenInterceptor.class
    )
    List<EvsiMarketOrderDTO> orders(@Var("characters") Integer characters);

    /**
     * 查询产品订单历史
     * */
    // https://esi.evetech.net/latest/characters/2119634223/orders/history/?datasource=tranquility&page=1&token=1%7CCfDJ8LAoxfuX0s1GlKTIRpDOTgpS39XG%2BBnCWVgig2lJDOuDwb77LdC%2BqdnZznECIZZQschmoO3YU%2F%2F91HbXekJgcW2wNuQZ732MCwFm0pP07aIvMCtHcX62zFqK0HVRM3PuHmxZOMc%2FNdjHKLLD%2FJIzm4DFBoAaSAz0prHPOjGCcX0o
    @Request(
            url = "/characters/{characters}/orders/history/?datasource=tranquility&page={page}",
            type = "GET",
            interceptor = TokenInterceptor.class
    )
    List<JSONObject> history(@Var("characters") Long characters, @Var("page") Integer pageNum);

    /**
     * 查询某地区的订单
     * */
    // https://esi.evetech.net/latest/markets/10000002/orders/?datasource=tranquility&order_type=buy&page=1
    @Request(
            url = "/markets/{regionId}/orders/?datasource=tranquility&order_type={orderType}&page={page}",
            type = "GET"
    )
    List<JSONObject> ordersByRegionId(@Var("regionId") String regionId, @Var("orderType") String orderType, @Var("page") Integer pageNum);

    /**
     * 查询某地区的订单类型
     * */
    // https://esi.evetech.net/latest/markets/10000002/types/?datasource=tranquility&page=1
    @Request(
            url = "/markets/{regionId}/types/?datasource=tranquility&page={page}",
            type = "GET"
    )
    List<Integer> types(@Var("regionId") String regionId, @Var("page") Integer pageNum);

    /**
     * 查询市场可发布订单的组
     * */
    // https://esi.evetech.net/latest/markets/groups/?datasource=tranquility
    @Request(
            url = "/markets/groups/?datasource=tranquility",
            type = "GET"
    )
    List<Integer> groups();

    /**
     * 通过组id查询组内详细信息
     * */
    // https://esi.evetech.net/latest/markets/groups/210/?datasource=tranquility&language=zh
    @Request(
            url = "/markets/groups/{marketGroupId}/?datasource=tranquility&language=zh",
            type = "GET",
            async = true
    )
    Future<JSONObject> groupsInfo(@Var("marketGroupId") Integer marketGroupId);
//    JSONObject groupsInfo(@Var("marketGroupId") Integer marketGroupId);

    /**
     * 市场调整价格以及平均价格
     */
    // https://esi.evetech.net/latest/markets/prices/?datasource=tranquility
    @Request(
            url = "/markets/prices/?datasource=tranquility",
            type = "GET"
    )
    List<JSONObject> prices();



    // /markets/structures/{structure_id}/


}
